﻿using Shinva.LADModel.Abstractions;
using Shinva.Variables.Interface;
using Shinva.Variables.Models;
using Shinva.Variables.Type.bit;
using Shinva.Variables.Type.combination;
using Shinva.Variables.Type.time;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shinva.LADModel.Type.TimerOperations
{
    public class CoilTON:ElementNodeBase
    {
        public PlcTime time { get;set; }
        public PlcStruct operand { get; set; }

        public override PlcBool EN
        {
            get
            {
                return en;
            }
            set
            {
                en = value;
            }
        }
        public override PlcBool ENO
        {
            get
            {

                eno.Value = en.Value;
                return eno;
            }
            set
            {
                eno = value;
            }
        }

        public CoilTON()
        {
            Name = "CoilTON";
            variableTableInterface.AddVariable("time", StorageType.Input);
            variableTableInterface.AddVariable("operand", StorageType.InOut);

            time = variableTableInterface.GetVariableValue<PlcTime>("time");
            operand = variableTableInterface.GetVariableValue<PlcStruct>("operand");
        }
        public override IPlcMember GetInterfaceVariableByName(string name)
        {
            if (name == "in") return en;
            else if(name=="out") return eno;
            else return variableTableInterface.GetVariableValue<IPlcMember>(name);
        }
    }
}
